#include "StdAfx.h"
#include ".\recvinfo.h"

RecvInfo::RecvInfo(void)
: SignedId(0)
, totalnum(0)
{
	lastrecv = CTime::GetCurrentTime();
}

RecvInfo::~RecvInfo(void)
{
}

void RecvInfo::AddSMS(int total, int seq, string ServiceId, string sms)
{
	totalnum = total;
	lastrecv = CTime::GetCurrentTime();
	this->ServiceId = ServiceId;
	infolist.insert(pair<int, string>(seq, sms));
}

string RecvInfo::GetSMS()
{
	string str;
	map<int, string>::const_iterator cp;
	for(cp=infolist.begin();cp!=infolist.end();cp++){
		str = str + cp->second;
	}
	return str;
}

bool RecvInfo::IsFinish(unsigned int time)
{
	if (totalnum == infolist.size()) {
		return true;
	} else {
		CTimeSpan cs(0, 0, time/60, time%60);
		CTime now = CTime::GetCurrentTime();
		if (now-lastrecv>=cs) {
			return true;
		} else {
			return false;
		}
	}
}